﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MpSoft.Library.DAO.Products;
using MpSoft.Library.DTO;
using MpSoft.Basic.Configuration;

namespace MpSoft.Library.BUSS.Products
{
    #region  Attribute

    public class AttributeBUSS
    {
        private const string attribute_ALL_KEY = "Mp.attribute.all-{0}";
        private const string attribute_BY_ID_KEY = "Mp.attribute.id-{0}";

        private static void AttributeRemoveCache()
        {
            MpCache.RemoveByPattern(attribute_ALL_KEY);
            MpCache.RemoveByPattern(attribute_BY_ID_KEY);
        }

        public static int Attribute_Add(AttributeE obj)
        {
            var result = AttributeDAO.Attribute_Add(obj);
            return result;
        }
        public static int Attribute_Update(AttributeE obj)
        {
            var result = AttributeDAO.Attribute_Update(obj);
            return result;
        }

        public static int Attribute_Delete(int AttributeID)
        {
            var result = AttributeDAO.Attribute_Delete(AttributeID);
            return result;
        }

        public static AttributeE Attribute_ByID(int AttributeID)
        {
            var list = Attribute_Select(AttributeID, 0, false);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static List<AttributeE> Attribute_Select(int AttributeID, int SortOrder, bool IsActive)
        {
            return AttributeDAO.Attribute_Select(AttributeID, SortOrder, IsActive);
        }

    }

    #endregion
}
